﻿<UserControl x:Class="LayoutPlanning.Views.LoadLayout"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:LayoutPlanning.Views"
        xmlns:pt="http://propertytools.org/wpf"
        mc:Ignorable="d"
         d:DesignHeight="685.58" d:DesignWidth="150.699"
         DataContext="{Binding Layouts, Source={StaticResource Locator}}">
    <Grid>
        <ListBox ScrollViewer.CanContentScroll="False"  x:Name="listBox" SelectedItem="{Binding SelectLayout}" HorizontalAlignment="Stretch"  ItemsSource="{Binding LayoutList}" Margin="4,78,4,4">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Height="180">
                        
                            <TextBox VerticalAlignment="Center" Text="{Binding LayoutName}" />
                            
                        <StackPanel Orientation="Horizontal" Height="100">
                        
                            <Viewbox  Width="150" Height="100" Stretch="UniformToFill">
                                <ContentControl VerticalAlignment="Stretch" HorizontalAlignment="Stretch"  Content="{Binding Layout.Element}" />
                            </Viewbox>
                            <!--<Button VerticalAlignment="Center" HorizontalAlignment="Right" Content="Load" Command="{Binding Layouts.LoadLayout, Source={StaticResource Locator}}" CommandParameter="{Binding}" />-->
                        </StackPanel>
                        <StackPanel Orientation="Horizontal" MinWidth="20">
                            <pt:SpinControl Maximum="1000000" MinWidth="80" SmallChange="100" Value="{Binding Width}" IsEnabled="{Binding Layout.Element.Content, Converter={StaticResource NullToBoolTrue}}">
                                <TextBlock Text="{Binding Width}" IsEnabled="{Binding Layout.Element.Content, Converter={StaticResource NullToBoolTrue}}"></TextBlock>
                            </pt:SpinControl>
                            <pt:SpinControl SmallChange="100" MinWidth="80"  Maximum="1000000" Value="{Binding Height}" IsEnabled="{Binding Layout.Element.Content, Converter={StaticResource NullToBoolTrue}}">
                                <TextBlock Text="{Binding Height}" IsEnabled="{Binding Layout.Element.Content, Converter={StaticResource NullToBoolTrue}}"></TextBlock>
                            </pt:SpinControl>
                            
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <Button Command="{Binding Browse}" Content="{Binding PointCloudButtonText}"></Button>
                            <Button HorizontalAlignment="Right" Width="80" Command="{Binding Layouts.DeleteLayout, Source={StaticResource Locator}}" CommandParameter="{Binding}"  Content="Delete Layout"></Button>

                        </StackPanel>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <Label x:Name="label" Content="Load Layout" Margin="7,11" HorizontalAlignment="Left" VerticalAlignment="Top"/>
        <Button x:Name="button" Content="Import new layout" Command="{Binding ImportNewLayout}" HorizontalAlignment="Right" Margin="0,0,4,0" VerticalAlignment="Top"   />
        <Button  Content="Create new empty" Command="{Binding CreateNewEmpty}" HorizontalAlignment="Right" Margin="0,25,4,0" VerticalAlignment="Top"   />
    </Grid>
</UserControl>







